/*********************************************************************\
*
*                  (c) lkc
*                  All Rights Reserved. lkc Confidential
*
\*********************************************************************/
/*********************************************************************\
*   Title                      :
*
*   Module Description         :
*
*   Author                     : lkc
*
*   Created                    : 2017-7-24
*
\*********************************************************************/
#include "GpioManage.h"
#include "UtilityTH.h"

const std::map<GpioPinNum, Gpio::Dir> ioInitPara =//IO初始化参数
{
    std::make_pair(GpioPinNum::MOTO_POWER_IO,Gpio::Dir::OUT),
    std::make_pair(GpioPinNum::CCD_POWER_IO,Gpio::Dir::OUT),
    std::make_pair(GpioPinNum::DISPLAY_EN_IO,Gpio::Dir::OUT),
    std::make_pair(GpioPinNum::AD5693_GAIN_RESET,Gpio::Dir::OUT),
    std::make_pair(GpioPinNum::AD5693_ADDR_PROG,Gpio::Dir::OUT),
    std::make_pair(GpioPinNum::ADV7180_PAL_RESET,Gpio::Dir::OUT),
};

GpioManage GpioManage::m_Instance;

GpioManage& GpioManage::GetInstance()
{
    return m_Instance;
}

GpioManage::GpioManage()
{
    DebugPrintf("GpioManage Constructors\n");
    for(const auto &kv:ioInitPara)
    {
        auto key = kv.first;
//        m_gpios.insert(std::make_pair(key, std::make_shared<Gpio>(static_cast<int>(key))));
        m_gpios.insert(std::make_pair(key, std::unique_ptr<Gpio>(new Gpio(static_cast<int>(key)))));
        m_gpios.at(key)->SetDirection(kv.second);
    }
}

//GpioManage::~GpioManage()
//{
//    KCPRINTF("GpioManage Destructors\n");
//}

void GpioManage::IoWrite(const GpioPinNum pinNum, const IoValue value)
{
    m_gpios.at(pinNum)->Write(value);
}
/********************************************************************\
 *
 * REVISION RECORDS
 *
\*********************************************************************/
/*********************************************************************/
/*
 *
 *
 *
\*********************************************************************/
/*------------------------------The End------------------------------*/

